<template>
  <a-card :bordered="false">
    <!-- 抽屉 -->
    <a-drawer
      title="设备列表"
      :width="screenWidth"
      @close="onClose"
      :visible="visible"
    >
      <!-- 抽屉内容的border -->
      <div
        :style="{
          padding:'10px',
          border: '1px solid #e9e9e9',
          background: '#fff',
        }">
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator" style="margin-bottom: 5px;">
          <a-button @click="handleAddRadio" type="primary" icon="plus">新增</a-button>
        </div>
        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"

            @change="handleTableChange">


            <template slot="avatarslot" slot-scope="text, record, index">
            <div class="anty-img-wrap">
              <img :src="getAvatarView(record)"/>
            </div>
          </template>

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
              <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
              <a-button
                v-else
                :ghost="true"
                type="primary"
                icon="download"
                size="small"
                @click="uploadFile(text)">
                下载
              </a-button>
            </template>
            <span slot="action" slot-scope="text, record">
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
        </span>
          </a-table>
        </div>

      </div>
    </a-drawer>
    <glr-light-pole-member-radio-list-add ref="modalForm" @ok="modalFormOk"></glr-light-pole-member-radio-list-add>
  </a-card>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { validateDuplicateValue,filterObj } from '@/utils/util'
  import GlrLightPoleMemberRadioListAdd from "./GlrLightPoleMemberRadioListAdd";

  export default {
    name: "GlrLightPoleMemberRadioList",
    mixins:[JeecgListMixin],
    components: {
      GlrLightPoleMemberRadioListAdd
    },
    data () {
      return {
        description: '音柱管理管理页面',
        visible: false,
        screenWidth: 800,
        lightPoleCode:"",
        deviceType:0,
        disableMixinCreated:true,
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'名称',
            align:"center",
            dataIndex: 'deviceName'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/glr/glrLightPoleDevice/lightPoleDeviceList",
          delete: "/glr/glrLightPoleDevice/delete",
          deleteBatch: "/glr/glrLightPoleDevice/deleteBatch",
        },
        dictOptions:{
        },
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      onClose() {
        this.visible = false;
        this.dataSource = [];
      },
      edit(record,memberType) {
        if (record.code) {
          this.lightPoleCode = record.code;
          this.deviceType=memberType;
        }
        this.model = Object.assign({}, record);
        this.model.lightPoleCode = this.lightPoleCode;
        this.model.deviceType = this.deviceType;
        this.visible = true;

        this.queryParam.lightPoleCode = this.lightPoleCode;
        this.queryParam.deviceType=this.deviceType;
        // 当其它模块调用该模块时,调用此方法加载字典数据
        this.loadData();
      },
      handleAddRadio: function () {
        this.$refs.modalForm.add(this.lightPoleCode,this.deviceType);
        this.$refs.modalForm.title = "新增";
        this.$refs.modalForm.disableSubmit = false;
      },
      getAvatarView: function (record) {
        if(record.glrLed.status=='Y'){
          return   require('@/assets/img/zaixian.png');
        }else{
          return   require('@/assets/img/lixian.png');
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>